<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="false">
			<block slot="content">首页</block>
		</cu-custom>
		<view class="content padding">
			<view class="user">
				<view style="white-space:normal; word-break:break-all;overflow:hidden;">{{userInfo}}</view>
			</view>
			<button class="cu-btn block bg-blue margin-tb-sm lg" @click="clickGoPatrol">开始巡检</button>
		</view>
	</view>
</template>

<script>
	import api from '../../util/apis/api-patrol.js';
	import ui from '../../util/ui.js';
	import {
		mapActions
	} from 'vuex';

	export default {
		data() {
			return {
				userInfo: ''
			}
		},
		onLoad() {
			// 获取用户信息
			this.getUserInfo()
		},
		onReady() {},
		methods: {
			// ————————————————————————————点击事件——————————————————————————
			/**
			 * 点击巡检按钮的时候
			 */
			clickGoPatrol: function() {
				uni.navigateTo({
					url: '../patrol/patrol_main'
				})
			},
			// ————————————————————————————api接口——————————————————————————
			/**
			 * 获取用户信息
			 */
			getUserInfo: function() {
				ui.showLoading()
				api.getUserInfo()
					.then(res => {
						this.$store.commit('SET_USER_INFO', res);
						this.userInfo = JSON.stringify(res)
					})
					.finally(() => {
						ui.hideLoading()
					})
			}
		},

	}
</script>

<style>
	.content {}

	.user {
		height: 200px;
		overflow: scroll;
	}
</style>
